package com.iv.durian.cloud.facade.support;

import com.iv.durian.cloud.Student;
import com.iv.durian.cloud.facade.StudentFacade;
import com.iv.durian.cloud.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class StudentFacadeImpl implements StudentFacade {

    @Autowired
    private StudentService studentService;

    @Override
    public Student get(@PathVariable(name = "studentId") Integer studentId){ return studentService.get(studentId); }

    @Override
    public Student get(@PathVariable(name = "name") String name) { return studentService.get(name); }

    @Override
    public void add(@RequestBody Student student){ studentService.add(student); }

    @Override
    public void update(@RequestBody Student student){ studentService.update(student); }

    @Override
    public int remove(@PathVariable(name = "studentId") Integer studentId){ return studentService.remove(studentId); }

    @Override
    public int count(@PathVariable(name = "studentId") Integer studentId){return studentService.count(studentId); }

    @Override
    public List<Student> list(@PathVariable(name = "studentId") Integer studentId, @PathVariable(name = "offset") Integer offset, @PathVariable(name = "limit") Integer limit) {
        return studentService.list(studentId,offset,limit);
    }


}
